﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Omes.Services;

namespace FashionMural.Web
{
    public partial class JSserver : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string meth = Request.HttpMethod;
            switch (meth)
            {
                case "GET":
                    {
                    }break;
                case "POST":
                    {
                        this.Post();
                    }break;
            }
        }

        protected void Get()
        {
        }

        protected void Post()
        {
            HttpContext context = HttpContext.Current;
            string result = string.Empty;
            string flag = Request.QueryString["who"];
            switch (flag)
            {
                case "single":
                    {
                        int userId = Convert.ToInt32(Request.Params["user"]);
                        int questionId = Convert.ToInt32(Request.Params["questionid"]);
                        int answerId = Convert.ToInt32(Request.Params["answerid"]);
                        Omes.Services.DbServer db = new DbServer();
                        db.AddQuestionAnswerSM(userId, questionId, answerId);
                    }break;
                case "self":
                    {
                        int userId = Convert.ToInt32(Request.Params["userid"]);
                        int questionId = Convert.ToInt32(Request.Params["questionid"]);
                        string answer = Request.Params["answer"];
                        Omes.Services.DbServer db = new DbServer();
                        db.AddQuestionAnswerS(userId, questionId, answer);
                    }break;
            }
        }
    }
}